<?php
class AdsHelper extends AppHelper
{
	var $helpers = array('Html');
	var $zoneAds = array();
	var $Ad;
	function show($zone)
	{
		if(!is_object($this->Ad))
		{
			$this->Ad = ClassRegistry::init('Ads.Ad');	
		}
		$zoneAds = $this->Ad->getZoneAddList($zone);
		$zoneAds = array_values($zoneAds);
		$code = false;
		if($zoneAds)
		{
			$randKey = 0;
			if(count($zoneAds) > 1)
			{
				$randKey = rand(0,count($zoneAds) -1);
			}
			$adId = $zoneAds[$randKey];
			$ad = $this->Ad->getAdInfo($adId);
			if($ad)
			{
				$code = $ad['Ad']['code'];
			}
		}
		return $code;
		//ClassRegistry::getObject('view')->element('show_add',array('adData'=>$adData));
		
			
	}
}
?>